package com.hashimoto.core.util;

import org.nustaq.serialization.FSTConfiguration;

public final class CopyUtil {
	
	private static FSTConfiguration CONF = FSTConfiguration.createAndroidDefaultConfiguration();
	static {
		CONF.setStructMode(true);
	}
	
	public static <T> T  copy(T t) {
		if(t == null) {
			throw new NullPointerException("The prototype object is null");
		}
		byte[] bytes = CONF.asByteArray(t);
		@SuppressWarnings("unchecked")
		T copy = (T)CONF.asObject(bytes);
		return copy;
	}
}
